﻿using CloudMusic.Helper;
using CloudMusic.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Reflection;
using Newtonsoft.Json;
using System.IO;
using System.Xml.Serialization;

namespace CloudMusic.View
{
    /// <summary>
    /// PageLocalMusic.xaml 的交互逻辑
    /// </summary>
    public partial class PageLocalMusic : Page
    {
        public PageLocalMusic()
        {
            InitializeComponent();
        }

        private void DataGrid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            CommonHelper.RunScorllView(sender, e);
        }

        private void LocalMusic_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = (ObservableCollection<MusicModel>)localMusic.ItemsSource;
            if (!PlayListHelper.MainMusicList.Any(t => t.Id == item[0].Id))
            {
                for (int i = 0; i < item.Count; i++)
                {
                    PlayModel music = new PlayModel
                    {
                        Index = item[i].Id.ToString(),
                        Url = item[i].Url,
                        Name = item[i].Name,
                        Size = item[i].Size,
                        Album = item[i].Album,
                        Artist = item[i].Artist,
                        TimeStr = item[i].TimeStr,
                        DownLoad = item[i].DownLoad,
                        PicUrl = item[i].PicUrl,
                        Id = item[i].Id,
                        SongId = item[i].SongId,
                        Type = item[i].Type,
                        SingerId = item[i].SingerId,
                        AlbumId = item[i].AlbumId,
                        VIPVis = item[i].VIPVis,
                        STVis = item[i].STVis,
                        SQVis = item[i].SQVis,
                        MVVis = item[i].MVVis,
                        CoverTitle = item[i].CoverTitle,
                        HighQuality = 3
                    };
                    PlayListHelper.MainMusicList.Add(music);
                }
            }
        }
    }
}
